﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceModel;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
using OChatWCFLib;
using System.Threading;

namespace OChatService
{
    public partial class OChat : ServiceBase
    {
        bool debug = true;

        public ServiceHost serviceHost;

        public OChat()
        {
            InitializeComponent();
            ServiceName = "OChatService";
        }

        protected override void OnStart(string[] args)
        {
            while (debug)
            {
                if (!debug)
                {
                    break;
                }
            }

            if (serviceHost != null)
            {
                serviceHost.Close();
            }

            serviceHost = new ServiceHost(typeof(OChatWCFLib.OChatService));

            serviceHost.Open();
        }

        protected override void OnStop()
        {
            if (serviceHost != null)
            {
                serviceHost.Close();
                serviceHost = null;
            }
        }

    }
}
